package com.itheima.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.LogDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.LogEntity;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogDao logDao;

    @Override
    public void saveLog(LogEntity logEntity) {
        logDao.insert(logEntity);
    }

    @Override
    public PageResult findPage(QueryPageBean queryPageBean, String date1, String date2) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<LogEntity> page = logDao.findByCondition(queryPageBean.getQueryString(),date1,date2);

        return new PageResult(page.getTotal(),page);
    }
}
